package uniLearn.data;

import java.math.BigDecimal;
import java.util.Date;

public class AssignmentResult {
	//variable
	private int acId;
	private String submitBy;
	private int agId;
	private String fileName;
	private Date submitTime;
	private SubmitStatus status;
	private BigDecimal mark;
	
	public AssignmentResult(int acId, String submitBy, int agId) {
		this.acId = acId;
		this.submitBy = submitBy;
		this.agId = agId;
		
		this.fileName = "";
		this.submitTime = new Date();
		this.status = SubmitStatus.unsubmit;
		this.mark = BigDecimal.ZERO;
	}

	//get method
	/**
	 * @return the acId
	 */
	public int getAcId() {
		return acId;
	}

	/**
	 * @return the submitBy
	 */
	public String getSubmitBy() {
		return submitBy;
	}

	/**
	 * @return the agId
	 */
	public int getAgId() {
		return agId;
	}

	/**
	 * @return the fileName
	 */
	public String getFileName() {
		return fileName;
	}

	/**
	 * @return the submitTime
	 */
	public Date getSubmitTime() {
		return submitTime;
	}

	/**
	 * @return the status
	 */
	public SubmitStatus getStatus() {
		return status;
	}

	/**
	 * @return the mark
	 */
	public BigDecimal getMark() {
		return mark;
	}

	//set method
	/**
	 * @param fileName the fileName to set
	 */
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	/**
	 * @param submitTime the submitTime to set
	 */
	public void setSubmitTime(Date submitTime) {
		this.submitTime = submitTime;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(SubmitStatus status) {
		this.status = status;
	}

	/**
	 * @param mark the mark to set
	 */
	public void setMark(BigDecimal mark) {
		this.mark = (mark == null || mark.signum() < 0) ? BigDecimal.ZERO : mark;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + acId;
		result = prime * result + agId;
		result = prime * result
				+ ((fileName == null) ? 0 : fileName.hashCode());
		result = prime * result + ((mark == null) ? 0 : mark.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		result = prime * result
				+ ((submitBy == null) ? 0 : submitBy.hashCode());
		result = prime * result
				+ ((submitTime == null) ? 0 : submitTime.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AssignmentResult other = (AssignmentResult) obj;
		if (acId != other.acId)
			return false;
		if (agId != other.agId)
			return false;
		if (fileName == null) {
			if (other.fileName != null)
				return false;
		} else if (!fileName.equals(other.fileName))
			return false;
		if (mark == null) {
			if (other.mark != null)
				return false;
		} else if (!mark.equals(other.mark))
			return false;
		if (status != other.status)
			return false;
		if (submitBy == null) {
			if (other.submitBy != null)
				return false;
		} else if (!submitBy.equals(other.submitBy))
			return false;
		if (submitTime == null) {
			if (other.submitTime != null)
				return false;
		} else if (!submitTime.equals(other.submitTime))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("AssignmentResult [acId=");
		builder.append(acId);
		builder.append(", submitBy=");
		builder.append(submitBy);
		builder.append(", agId=");
		builder.append(agId);
		builder.append(", fileName=");
		builder.append(fileName);
		builder.append(", submitTime=");
		builder.append(submitTime);
		builder.append(", status=");
		builder.append(status);
		builder.append(", mark=");
		builder.append(mark);
		builder.append("]");
		return builder.toString();
	}

	
}
